updating oE map get

get

include map.e 
namespace map 
public function get(map the_map_p, object key, object default = 0) 

retrieves the value associated to a key in a map.

Parameters:
  1. the_map_p : the map to inspect
  2. the_key_p : an object, the the_key_p being looked tp
  3. default_value_p : an object, a default value returned if the_key_p not found. The default is 0.
Returns:

An object, the value that corresponds to the_key_p in the_map_p. If the_key_p is not in the_map_p, default_value_p is returned instead.

Example 1:
map ages 
ages = new() 
put(ages, "Andy", 12) 
put(ages, "Budi", 13) 
 
integer age 
age = get(ages, "Budi", -1) 
if age = -1 then 
    puts(1, "Age unknown") 
else 
    printf(1, "The age is %d", age) 
end if 
See Also:

has

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu